new Handle:g_Save = INVALID_HANDLE
new Handle:g_SaveDelay = INVALID_HANDLE
new Handle:m_timer = INVALID_HANDLE
new Handle:m_DoSave

public Action:Save(client, args)
{
	if (Synergy)
	{
		if(GetConVarInt(g_Save) == 1)
		{
			CreateTimer(0.1, DO_Save)
			PrintToConsole(client,"[SM] Game was Saved.")
			if (Debug)
				PrintToServer("SAVING")
		}
		else if(GetConVarInt(g_Save) == 0)
		{
			PrintToConsole(client,"[SM] Saving is Disabled.")
			if (Debug)
				PrintToServer("DISABLED")
		}
	}
	return Plugin_Handled
}

public Action:DO_Save(Handle:timer)
{
	if(GetConVarInt(g_Save) == 1 && GetRealClientCount(true) > 0){
		SDKCall(m_DoSave)
		if (Debug)
			PrintToChatAll("save")
	}
	else if (GetRealClientCount(true) <= 0){
		PrintToServer("No Players on the Server to save.")
		DO_KillTimer()
	}
	return Plugin_Handled
}

DO_KillTimer()
{
	if (m_timer != INVALID_HANDLE){
		KillTimer(m_timer)
	}
	m_timer = INVALID_HANDLE
	if (Debug)
		PrintToChatAll("timer killed")
}